// import { formatDate } from "./format.js"

const operate = function(val1,val2) {
    let midarr = []
    //判断local中是否存在
    if(!localStorage.getItem("localoperatelist")){
        localStorage.setItem('localoperatelist',JSON.stringify(midarr))
    }
    //定义操作信息对象
    let datenow = new Date()
    let myyear = datenow.getFullYear();    //获取完整的年份(4位,1970-????)
    let mymonth =parseInt(datenow.getMonth()) + 1;       //获取当前月份(0-11,0代表1月)
    let mydate =datenow.getDate();
    let mytime = datenow.toLocaleTimeString()
    let total = myyear + "-" + mymonth + "-" + mydate + " " + mytime
    let operateinfo = {
        operateip: localStorage.getItem("Ip"),
        operatetime: total,
        operatename: val1,
        operatetype: val2,     
        operatecity: localStorage.getItem("cityname")   
    }
    //将操作信息对象push到midarr中，在存放到local中
    midarr = JSON.parse(localStorage.getItem("localoperatelist"))
    midarr.push(operateinfo)
    localStorage.setItem('localoperatelist',JSON.stringify(midarr))
    
}
export default operate